001: package org.tigris.scarab.om;
002:
003: /* ================================================================
004: * Copyright (c) 2000-2005 CollabNet. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are
008: * met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: *
017: * 3. The end-user documentation included with the redistribution, if
018: * any, must include the following acknowlegement: "This product includes
019: * software developed by Collab.Net <http://www.Collab.Net/>."
020: * Alternately, this acknowlegement may appear in the software itself, if
021: * and wherever such third-party acknowlegements normally appear.
022: *
023: * 4. The hosted project names must not be used to endorse or promote
024: * products derived from this software without prior written
025: * permission. For written permission, please contact info@collab.net.
026: *
027: * 5. Products derived from this software may not use the "Tigris" or
028: * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
029: * prior written permission of Collab.Net.
030: *
031: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034: * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037: * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039: * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042: *
043: * ====================================================================
044: *
045: * This software consists of voluntary contributions made by many
046: * individuals on behalf of Collab.Net.
047: */
048: import com.workingdogs.village.DataSetException;
049: import java.util.List;
050: import java.util.Locale;
051: import java.util.Map;
052: import java.util.Calendar;
053:
054: import org.apache.fulcrum.security.entity.Role;
055: import org.apache.fulcrum.security.entity.User;
056: import org.apache.fulcrum.security.util.AccessControlList;
057: import org.apache.fulcrum.security.util.DataBackendException;
058: import org.apache.fulcrum.security.util.EntityExistsException;
059: import org.apache.fulcrum.security.util.TurbineSecurityException;
060: import org.apache.torque.om.ObjectKey;
061: import org.apache.torque.om.Persistent;
062: import org.apache.torque.TorqueException;
063:
064: import org.tigris.scarab.reports.ReportBridge;
065: import org.tigris.scarab.util.ScarabException;
066:
067: /**
068: * This is an interface which describes what a ScarabUser is...
069: *
070: * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
071: * @version $Id: ScarabUser.java 10285 2006-09-08 16:48:22Z jorgeuriarte $
072: */
073: public interface ScarabUser extends User, Persistent {
074: public static String DELETED = "DELETED";
075:
076: /**
077: * This method is responsible for creating a new user. It will throw an
078: * exception if there is any sort of error (such as a duplicate login id)
079: * and place the error message into e.getMessage(). This also creates a
080: * uniqueid and places it into this object in the perm table under the
081: * Visitor.CONFIRM_VALUE key. It will use the current instance of this
082: * object as the basis to create the new User.
083: */
084: void createNewUser() throws TorqueException, DataBackendException,
085: EntityExistsException;
086:
087: /**
088: * Gets all modules the user has permissions to edit.
089: * The default is to not show global modules if you have
090: * the permission to edit it.
091: * @see #getEditableModules(Module)
092: */
093: List getEditableModules() throws TorqueException;
094:
095: /**
096: * Gets all modules the user has permissions to edit.
097: * @param currEditModule the module we are currently editing
098: */
099: List getEditableModules(Module currEditModule)
100: throws TorqueException;
101:
102: /**
103: * Gets all modules the user is associated to, except the Global one.
104: * @return
105: * @throws TorqueException
106: */
107: List getNonGlobalModules() throws TorqueException;
108:
109: /**
110: * Gets an issue stored in the temp hash under key.
111: *
112: * @param key a <code>String</code> used as the key to retrieve the issue
113: * @return an <code>Issue</code> value
114: * @exception Exception if an error occurs
115: */
116: Issue getReportingIssue(String key) throws TorqueException;
117:
118: /**
119: * Places an issue into the session that can be retrieved using the key
120: * that is returned from the method.
121: *
122: * @param issue an <code>Issue</code> to store in the session under a
123: * new key
124: * @return a <code>String</code> value that can be used to retrieve
125: * the issue
126: * @exception ScarabException if issue is null.
127: */
128: String setReportingIssue(Issue issue) throws ScarabException;
129:
130: /**
131: * Places an issue into the session under the given key. If another issue
132: * was already using that key, it will be overwritten. Giving a null issue
133: * removes any issue stored using key. This method is primarily used to
134: * remove the issue from storage. Inserting a new issue would be most
135: * likely done with setReportingIssue(Issue issue).
136: *
137: * @param key a <code>String</code> value under which to store the issue
138: * @param issue an <code>Issue</code> value to store, null removes any
139: * issue already stored under key.
140: */
141: void setReportingIssue(String key, Issue issue);
142:
143: /**
144: * Gets an report stored in the temp hash under key.
145: *
146: * @param key a <code>String</code> used as the key to retrieve the report
147: * @return an <code>Report</code> value
148: * @exception Exception if an error occurs
149: */
150: ReportBridge getCurrentReport(String key) throws TorqueException;
151:
152: /**
153: * Places an report into the session that can be retrieved using the key
154: * that is returned from the method.
155: *
156: * @param report an <code>ReportBridge</code> to store in the session under a
157: * new key
158: * @return a <code>String</code> value that can be used to retrieve
159: * the report
160: * @exception ScarabException if report is null.
161: */
162: String setCurrentReport(ReportBridge report) throws ScarabException;
163:
164: /**
165: * Places an report into the session under the given key. If another report
166: * was already using that key, it will be overwritten. Giving a null report
167: * removes any report stored using key. This method is primarily used to
168: * remove the report from storage. Inserting a new report would be most
169: * likely done with setCurrentReport(ReportBridge report).
170: *
171: * @param key a <code>String</code> value under which to store the report
172: * @param report an <code>ReportBridge</code> value to store, null removes any
173: * report already stored under key.
174: */
175: void setCurrentReport(String key, ReportBridge report);
176:
177: /** Used for the password management features */
178: boolean isPasswordExpired() throws TorqueException, ScarabException;
179:
180: /** Used for the password management features */
181: void setPasswordExpire() throws TorqueException;
182:
183: /** Used for the password management features */
184: void setPasswordExpire(Calendar expire) throws TorqueException;
185:
186: Integer getUserId();
187:
188: void setUserId(Integer v) throws TorqueException;
189:
190: ObjectKey getPrimaryKey();
191:
192: void setPrimaryKey(ObjectKey v) throws TorqueException;
193:
194: /**
195: * Returns list of RModuleUserAttribute objects for this
196: * User and Module -- the attributes the user has selected
197: * To appear on the IssueList for this module.
198: */
199: List getRModuleUserAttributes(Module module, IssueType issueType)
200: throws TorqueException;
201:
202: /**
203: * Returns an RModuleUserAttribute object.
204: */
205: RModuleUserAttribute getRModuleUserAttribute(Module module,
206: Attribute attribute, IssueType issueType)
207: throws TorqueException, ScarabException;
208:
209: /**
210: * Implementation of the Retrievable interface because this object
211: * is used with Intake
212: */
213: String getQueryKey();
214:
215: /**
216: * Implementation of the Retrievable interface because this object
217: * is used with Intake
218: */
219: void setQueryKey(String key) throws TorqueException;
220:
221: /**
222: * Returns true if this user has the given permission within the given
223: * module, false otherwise.
224: *
225: * @param permission a <code>String</code> permission value, which should
226: * be a constant in this interface.
227: * @param module a <code>Module</code> value
228: * @return true if the permission exists for the user within the
229: * given module, false otherwise
230: */
231: boolean hasPermission(String permission, Module module);
232:
233: /**
234: * Returns true if this user has the given permission within all the given
235: * modules, false otherwise. If the list is null or empty
236: */
237: boolean hasPermission(String permission, List modules);
238:
239: /**
240: * Gets all modules which are currently associated with this user
241: * (relationship has not been deleted.)
242: */
243: List getModules() throws TorqueException;
244:
245: /**
246: * Gets all modules which are currently associated with this user.
247: * @param showDeletedModules show modules which have been marked as deleted
248: */
249: List getModules(boolean showDeletedModules) throws TorqueException;
250:
251: /**
252: * Get a list of <code>Module</code>'s that where a user has
253: * the specified permission. Does not show deleted modules.
254: * (showDeleted = false)
255: * @param permission a <code>String</code> value
256: * @return a <code>Module[]</code> value
257: */
258: Module[] getModules(String permission) throws TorqueException;
259:
260: /**
261: * Get a list of <code>Module</code>'s that where a user has
262: * at least one of the permissions given. Does not show deleted modules.
263: * (showDeleted = false)
264: * @param permissions a <code>String[]</code> value
265: * @return a <code>Module[]</code> value
266: */
267: Module[] getModules(String[] permissions) throws TorqueException;
268:
269: /**
270: * Get a list of <code>Module</code>'s that where a user has
271: * at least one of the permissions given. Does not show deleted modules.
272: *
273: * @param permissions a <code>String[]</code> value
274: * @param showDeleted a <code>boolean</code> value
275: * @return a <code>Module[]</code> value
276: */
277: Module[] getModules(String[] permissions, boolean showDeleted)
278: throws TorqueException;
279:
280: List getCopyToModules(Module currentModule) throws TorqueException;
281:
282: List getCopyToModules(Module currentModule, String action)
283: throws TorqueException;
284:
285: List getCopyToModules(Module currentModule, String action,
286: String searchString) throws TorqueException;
287:
288: /**
289: * Determine whether the user has any role in the given module.
290: * This only checks roles directly in this module, not in the "Global"
291: * module.
292: *
293: * @param module a <code>Module</code> value
294: * @return a <code>boolean</code> value
295: */
296: boolean hasAnyRoleIn(Module module) throws TorqueException;
297:
298: /**
299: * The user's full name.
300: */
301: String getName();
302:
303: /**
304: * Sets integer representing user preference for
305: * Which screen to return to after entering an issue.
306: */
307: void setEnterIssueRedirect(int templateCode) throws TorqueException;
308:
309: /**
310: * Returns integer representing user preference for
311: * Which screen to return to after entering an issue.
312: */
313: int getEnterIssueRedirect() throws TorqueException;
314:
315: /**
316: * The template/tab to show for the home page using the current module.
317: */
318: String getHomePage() throws TorqueException;
319:
320: /**
321: * The template/tab to show for the home page in the given module.
322: */
323: String getHomePage(Module module) throws TorqueException;
324:
325: /**
326: * The template/tab to show for the home page.
327: */
328: void setHomePage(String homePage) throws TorqueException,
329: ScarabException;
330:
331: /**
332: * The template to show if the user is going to start a new query.
333: * if the user has not selected a set of issue types it will return
334: * IssueTypeList.vm. If a list is already selected, then it will go to
335: * AdvancedQuery.vm unless the list is only one issue type and the user
336: * has last selected Custom query for that issue type.
337: */
338: public String getQueryTarget();
339:
340: /**
341: * Setup the users preference when entering a query for the given
342: * issue type. Valid values of target are AdvancedQuery.vm
343: * and Search.vm (Custom query).
344: */
345: public void setSingleIssueTypeQueryTarget(IssueType type,
346: String target);
347:
348: List getMITLists() throws TorqueException;
349:
350: /**
351: * Checks if the user can search for issues of at least one issue type
352: * in one module.
353: */
354: public boolean hasAnySearchableRMITs() throws TorqueException,
355: DataSetException;
356:
357: /**
358: * Returns a List of RModuleIssueTypes for which the user has the
359: * permission to search for issues.
360: *
361: * @param skipModule do not include issue types for this module. Useful
362: * for separating the current module.
363: * @return a <code>List</code> value
364: * @exception Exception if an error occurs
365: */
366: List getSearchableRMITs(String searchField, String searchString,
367: String sortColumn, String sortPolarity, Module skipModule)
368: throws TorqueException;
369:
370: /**
371: * returns a list of RModuleIssueTypes for the given module, excluding
372: * any that that have a corresponding MITListItem in the CurrentMITList.
373: */
374: public List getUnusedRModuleIssueTypes(Module module)
375: throws TorqueException;
376:
377: /**
378: * returns a list of RModuleIssueTypes for the given module.
379: */
380: public List getAllRModuleIssueTypes(Module module)
381: throws TorqueException;
382:
383: void addRMITsToCurrentMITList(List rmits) throws TorqueException;
384:
385: MITList getCurrentMITList();
386:
387: void setCurrentMITList(MITList list);
388:
389: void removeItemsFromCurrentMITList(String[] ids);
390:
391: Object lastEnteredIssueTypeOrTemplate();
392:
393: void setLastEnteredIssueType(IssueType type);
394:
395: void setLastEnteredTemplate(Issue template);
396:
397: /**
398: * The most recent query entered. This method has the effect of loading
399: * the MITList used for the query (if one exists) as the CurrentMITList
400: * so it should only be called if the query is to be used.
401: * Use @see #hasMostRecentQuery() to determine existence.
402: */
403: String getMostRecentQuery();
404:
405: /**
406: * The most recent query entered.
407: */
408: void setMostRecentQuery(String queryString);
409:
410: /**
411: * Check if the user has a previous query
412: */
413: boolean hasMostRecentQuery();
414:
415: /**
416: * key used to keep concurrent activities by the same
417: * user from overwriting each others state.
418: */
419: Object getThreadKey();
420:
421: /**
422: * key used to keep concurrent activities by the same
423: * user from overwriting each others state.
424: */
425: void setThreadKey(Integer key);
426:
427: /**
428: * Get the working list of associated users
429: * For the AssignIssue screen
430: */
431: Map getAssociatedUsersMap() throws TorqueException;
432:
433: /**
434: * Set the working list of associated users
435: * For the AssignIssue screen
436: */
437: void setAssociatedUsersMap(Map associatedUsers)
438: throws TorqueException;
439:
440: /**
441: * Get the working list of associated users
442: * For the AssignIssue screen
443: */
444: Map getSelectedUsersMap() throws TorqueException;
445:
446: /**
447: * Set the working list of associated users
448: * For the AssignIssue screen
449: */
450: void setSelectedUsersMap(Map selectedUsers) throws TorqueException;
451:
452: /**
453: * The current module which represents the module
454: * selected by the user within a request.
455: */
456: Module getCurrentModule();
457:
458: /**
459: * The current module which represents the module
460: * selected by the user within a request.
461: */
462: void setCurrentModule(Module v);
463:
464: /**
465: * The current issue type which represents the issue type
466: * selected by the user within a request.
467: */
468: IssueType getCurrentIssueType() throws TorqueException;
469:
470: /**
471: * The current issue type which represents the issue type
472: * selected by the user within a request.
473: */
474: void setCurrentIssueType(IssueType v);
475:
476: /**
477: * The current RModuleIssueType which represents the module and issue type
478: * selected by the user within a request.
479: */
480: RModuleIssueType getCurrentRModuleIssueType()
481: throws TorqueException;
482:
483: /**
484: * Updates the attributes shown in IssueList.vm
485: * Removes any saved preferences for the current mit list or current module
486: * and issue type. And replaces them with the attributes given.
487: * The order of the attributes is preserved.
488: */
489: void updateIssueListAttributes(List attributes)
490: throws TorqueException, TurbineSecurityException;
491:
492: List getRoleNames(Module module) throws TorqueException;
493:
494: /**
495: * Set the user's locale to a new value.
496: */
497: void setLocale(Locale newLocale);
498:
499: /**
500: * Get the user's current locale.
501: */
502: Locale getLocale();
503:
504: /**
505: * Get the user's preferred locale.
506: */
507: Locale getPreferredLocale();
508:
509: /**
510: * Get the ShowOtherModulesInIssueTypeList value.
511: * toggle switch for show/hide the cross module section of the
512: * issue type selection widget.
513: * @return the ShowOtherModulesInIssueTypeList value.
514: */
515: public boolean isShowOtherModulesInIssueTypeList();
516:
517: /**
518: * Set the ShowOtherModulesInIssueTypeList value.
519: * toggle switch for show/hide the cross module section of the
520: * issue type selection widget.
521: * @param newShowOtherModulesInIssueTypeList The new
522: * ShowOtherModulesInIssueTypeList value.
523: */
524: public void setShowOtherModulesInIssueTypeList(
525: boolean newShowOtherModulesInIssueTypeList);
526:
527: /**
528: * Returns true if the user is the one set in scarab.anonymous.username, and
529: * false otherwise.
530: * @return
531: */
532: public boolean isUserAnonymous();
533:
534: public List getAssignIssuesList();
535:
536: public AccessControlList getACL();
537:
538: public boolean hasRoleInModule(Role role, Module module);
539:
540: }
|