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: UserRightFilter.java,v $
031: * Revision 1.2 2005/04/09 17:19:07 colinmacleod
032: * Changed copyright text to GPL v2 explicitly.
033: *
034: * Revision 1.1.1.1 2005/03/10 17:50:35 colinmacleod
035: * Restructured ivata op around Hibernate/PicoContainer.
036: * Renamed ivata groupware.
037: *
038: * Revision 1.4 2004/07/13 19:41:14 colinmacleod
039: * Moved project to POJOs from EJBs.
040: * Applied PicoContainer to services layer (replacing session EJBs).
041: * Applied Hibernate to persistence layer (replacing entity EJBs).
042: *
043: * Revision 1.3 2004/03/21 21:16:06 colinmacleod
044: * Shortened name to ivata op.
045: *
046: * Revision 1.2 2004/02/01 22:00:32 colinmacleod
047: * Added full names to author tags
048: *
049: * Revision 1.1.1.1 2004/01/27 20:57:51 colinmacleod
050: * Moved ivata openportal to SourceForge..
051: *
052: * Revision 1.3 2003/10/17 12:36:12 jano
053: * fixing problems with building
054: * converting intranet -> portal
055: * Eclipse building
056: *
057: * Revision 1.2 2003/10/15 13:18:02 colin
058: * fixing for XDoclet
059: *
060: * Revision 1.1 2003/02/24 19:09:21 colin
061: * moved to business
062: *
063: * Revision 1.4 2003/02/04 17:43:45 colin
064: * copyright notice
065: *
066: * Revision 1.3 2002/06/21 12:48:58 colin
067: * restructured com.ivata.groupware.web
068: *
069: * Revision 1.2 2002/06/17 07:28:44 colin
070: * improved and extended javadoc documentation
071: *
072: * Revision 1.1 2002/06/13 11:21:24 colin
073: * first version with rose model integration.
074: * -----------------------------------------------------------------------------
075: */
076: package com.ivata.groupware.business.addressbook.person.group.right;
077:
078: import java.io.IOException;
079: import java.io.ObjectInputStream;
080: import java.io.ObjectOutputStream;
081: import java.io.Serializable;
082:
083: /**
084: * <p>Some classes access the system on the basis of user rights, and use this
085: * class to filter the results according to the parameters given</p>
086: *
087: * <p>The parameters here are the same as for
088: * {@link RightLocalHome#findTargetIdByUserNameAccessDetail
089: * RightLocalHome.findTargetIdByUserNameAccessDetail}.</p>
090: *
091: * @since 2002-05-19
092: * @author Colin MacLeod
093: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
094: * @see RightLocalHome#findTargetIdByUserNameAccessDetail
095: * @version $Revision: 1.2 $
096: */
097: public class UserRightFilter implements Serializable {
098:
099: /**
100: * <p>Default constructor.</p>
101: */
102: public UserRightFilter() {
103: super ();
104: }
105:
106: /**
107: * <p>Construct a user right filter from all its fields.</p>
108: *
109: * @param userName the user to filter results for. See {@link #setUserName
110: * setUserName}.
111: * @param access the access type. See {@link #setAccess setAccess}.
112: * @param detail the specific user right you want to filter against. See
113: * {@link #setDetail setDetail}.
114: */
115: public UserRightFilter(String userName, Integer access,
116: Integer detail) {
117: setUserName(userName);
118: setAccess(access);
119: setDetail(detail);
120: }
121:
122: /**
123: * <p>Stores the name of the user for whom the results will be filtered.</p>
124: */
125: private String userName = null;
126:
127: /**
128: * <p>Stores the access type. This parameter should be set to one of the 'ACCESS_...'
129: * constants in {@link RightConstants RightConstants}.</p>
130: *
131: * @see RightConstants
132: */
133: private Integer access = null;
134:
135: /**
136: * <p>Get the access type. This parameter should be set to one of the 'ACCESS_...'
137: * constants in {@link RightConstants RightConstants}.</p>
138: *
139: * @return the access type.
140: * @see RightConstants
141: */
142: private Integer detail = null;
143:
144: /**
145: * <p>Get the access type. This parameter should be set to one of the 'ACCESS_...'
146: * constants in {@link RightConstants RightConstants}.</p>
147: *
148: * @return the value of the access type.
149: * @see RightConstants
150: */
151: public final Integer getAccess() {
152: return access;
153: }
154:
155: /**
156: * <p>Get the detail of the user right being checked. This parameter should
157: * be set to one of the 'DETAIL_...' constants in
158: * {@link RightConstants RightConstants}.</p>
159: *
160: * @return the user right detail.
161: * @see RightConstants
162: */
163: public final Integer getDetail() {
164: return detail;
165: }
166:
167: /**
168: * <p>Get the name of the user for whom the results will be filtered.</p>
169: *
170: * @return the name of the user for whom the results will be filtered.
171: */
172: public final String getUserName() {
173: return userName;
174: }
175:
176: /**
177: * <p>Set the access type. This parameter should be set to one of the 'ACCESS_...'
178: * constants in {@link RightConstants RightConstants}.</p>
179: *
180: * @param access the new value of the access type.
181: * @see RightConstants
182: */
183: public final void setAccess(final Integer access) {
184: this .access = access;
185: }
186:
187: /**
188: * <p>Set the detail of the user right being checked. This parameter should
189: * be set to one of the 'DETAIL_...' constants in
190: * {@link RightConstants RightConstants}.</p>
191: *
192: * @param detail the new value of the user right detail.
193: * @see RightConstants
194: */
195: public final void setDetail(final Integer detail) {
196: this .detail = detail;
197: }
198:
199: /**
200: * <p>Set the name of the user for whom the results will be filtered.</p>
201: *
202: * @param userName new name for the user for whom the results will
203: * be filtered.
204: */
205: public final void setUserName(final String userName) {
206: this .userName = userName;
207: }
208:
209: /**
210: * <p>Serialize the object to the output stream provided.</p>
211: *
212: * @exception IOException thrown by
213: * <code>ObjectOutputStream.defaultWriteObject( )</code>
214: * @param oos the output stream to serialize the object to
215: */
216: private void writeObject(final ObjectOutputStream oos)
217: throws IOException {
218: oos.defaultWriteObject();
219: }
220:
221: /**
222: * <p>Serialize the object from the input stream provided.</p>
223: *
224: * @exception ClassNotFoundException thrown by
225: * <code>ObjectInputStream.defaultReadObject</code>.
226: * @exception IOException thrown by
227: * <code>ObjectInputStream.defaultReadObject</code>.
228: * @param ois the input stream to serialize the object from
229: */
230: private void readObject(final ObjectInputStream ois)
231: throws ClassNotFoundException, IOException {
232: ois.defaultReadObject();
233: }
234:
235: /**
236: * <p>Comparison method. See if the object supplied is a user right filter and,
237: * if so, whether or not its contents are the same as this one.</p>
238: *
239: * @param compare the object to compare with this one.
240: * @return <code>true</code> if the filter supplied in <code>compare</code>
241: * is effectively the same as this one, otherwise false.
242: */
243: public boolean equals(final Object compare) {
244: // first check it is non-null and the class is right
245: if ((compare == null) || !(this .getClass().isInstance(compare))) {
246: return false;
247: }
248: UserRightFilter filter = (UserRightFilter) compare;
249:
250: // check that the user names, access and detail are the same for both
251: return (((userName == null) ? (filter.userName == null)
252: : userName.equals(filter.userName))
253: && ((access == null) ? (filter.access == null) : access
254: .equals(filter.access)) && ((detail == null) ? (filter.detail == null)
255: : detail.equals(filter.detail)));
256: }
257: }
|