okapi.coreobjects
Class OkapiUser

java.lang.Object
  extended by okapi.coreobjects.OkapiObject
      extended by okapi.coreobjects.OkapiUser
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class OkapiUser
extends OkapiObject
implements java.lang.Comparable

A class representing a single user (student, TA, faculty, etc) in an OkapiSite. Does not contain methods for adding or removing users to an OkapiSite.

Version:
$Revision: 31375 $, $Date: 2008-11-25 20:06:31 -0500 (Tue, 25 Nov 2008) $
Author:
MIT Stellar team
See Also:
eduperson, Serialized Form

Field Summary
static OkapiUser content_developerRoleUser
           
static OkapiUser course_administratorRoleUser
           
static OkapiUser graderRoleUser
           
static OkapiUser guestRoleUser
           
static OkapiUser help_desk_staffRoleUser
           
static OkapiUser instructorRoleUser
           
static OkapiUser learnerRoleUser
           
static OkapiUser managerRoleUser
           
static OkapiUser mentorRoleUser
           
static OkapiUser nobodyUser
           
static OkapiUser nullUser
           
static java.util.HashMap PERSONAL
          Options constant for getAsXml methods indicating personal information only.
static OkapiUser studentRoleUser
           
static OkapiUser superUser
          Systemwide standard users for internal utility.
static OkapiUser system_administratorRoleUser
           
static OkapiUser taRoleUser
           
 
Fields inherited from class okapi.coreobjects.OkapiObject
createdBy, createdDate, description, lastModifiedBy, lastModifiedDate, longName, name, objectID, status
 
Constructor Summary
OkapiUser()
          Create a new empty User Object.
OkapiUser(int userCode)
          Return new User object with values for user with this userCode
OkapiUser(java.lang.String username)
          Return new User object for user with this username.
 
Method Summary
 void addAddresses(java.lang.String type, OkapiUserAddress address)
          Add or update address of specified type.
 void addContactInfo(java.lang.String type, OkapiUserContactInfo contactInfo)
          Add or update contactInfo of specified type.
static int cacheCheck()
          Method cacheCheck
static int cacheNameCheck()
          Method cacheNameCheck
 boolean checkAuthorization(OkapiUser user, OkapiOperation operation)
          Checks to see if the specified user is authorized to perform the specified operation on this object.
 int compareTo(java.lang.Object o)
          implement Comparable interface
 int compareTo(OkapiUser user)
          Method compareTo
 int compareTo(java.lang.String o)
          Method compareTo
 boolean equals(java.lang.Object o)
          override Object equals method to compare two users
 java.util.Map getAddresses()
          Return all addresses of this user.
 OkapiUserAddress getAddresses(java.lang.String type)
          Return address of specified type for this user.
 java.lang.String getAffiliation()
          Return the affiliation for this OkapiUser.
 java.lang.String getAsXml(java.util.Map options, java.lang.String tag, int indent)
          Overrides the method in OkapiObject to add Content specific information.
 java.lang.Object getAttributeByKey(java.lang.Object key)
          Return an attribute for this OkapiUser.
 java.util.Map getAttributes()
          Return the attributes Hashtable for this OkapiUser.
 java.util.Map getContactInfo()
          Return all contactInfo of this user.
 OkapiUserContactInfo getContactInfo(java.lang.String type)
          Return contactInfo of specified type for this user.
 java.lang.String getEmail()
          Return the email address for this OkapiUser.
 java.lang.String getFirstName()
          Return the firstName for this OkapiUser.
 java.lang.String getFullName()
          Return the fullName for this OkapiUser.
 java.lang.String getLastName()
          Return the lastName for this OkapiUser.
 java.lang.String getLocalID()
          Return the localID for this OkapiUser.
 java.lang.String getMiddleName()
          Return the middleName for this OkapiUser.
 java.util.Map getNexuses()
          Return the nexuses in which the User has a Role or Roles.
 java.lang.String getNickName()
          Return the nickName for this OkapiUser.
 java.util.Properties getPreferenceProperties()
          Return all preferenceProperties of this user.
 java.lang.String getPreferenceProperty(java.lang.String key)
          Return specified preferenceProperties for this user.
 java.lang.String getPreferenceProperty(java.lang.String key, java.lang.String defaultValue)
          Return specified preferenceProperties for this user, or the defaultValue if no preference is set.
 OkapiSession getSession()
          Method getSession
static OkapiUser getUser(int userCode)
          Get a user from the cache if cached, instantiate and add to cache if not.
static OkapiUser getUser(java.lang.String username)
          Get a user from the cache if cached, instantiate and add to cache if not.
 int getUserCode()
          Return userCode of this user.
 java.lang.String getUserName()
          Return the userName for this OkapiUser.
 int hashCode()
          override hashCode to use the database table sequence number
static OkapiUser lookupUserByEmail(java.lang.String email)
          Return user with given email address, or null
static java.util.List lookupUsers(java.lang.String nameQuery)
          Return list of users matching query
 void refreshFromDB()
          Refresh this object with the data currently stored in the DB.
static OkapiUser refreshUser(java.lang.String username)
          Refresh user in the cache if cached, instantiate and add to cache if not.
 void removeAddresses(java.lang.String type)
          Remove address of specified type for this user.
 void removeContactInfo(java.lang.String type)
          Remove contactInfo of specified type for this user.
 void resetAuthorization()
          Method resetAuthorization
protected  java.util.List roleInNexus(java.lang.Integer nexusCode)
          Return the User's Role(s) in the specified Nexus (by nexusCode).
 java.util.List roleInNexus(OkapiNexus nexus)
          Return the User's Role(s) in the specified Nexus.
 void setAddresses(java.util.Map newAddresses)
          Set all addresses for this user.
 void setAffiliation(java.lang.String affiliation)
          Set the affiliation for this OkapiUser.
 void setAttribute(java.lang.Object key, java.lang.Object value)
          Set an attribute for this OkapiUser.
 void setContactInfo(java.util.Map newContactInfo)
          Set all contactInfo for this user.
 void setDataSource(javax.sql.DataSource dataSource)
          Set the dataSource to be used for data access.
 void setEmail(java.lang.String email)
          Set the email address for this OkapiUser.
 void setFirstName(java.lang.String firstName)
          Set the firstName for this OkapiUser.
 void setFullName(java.lang.String fullName)
          Set the fullName for this OkapiUser.
 void setLastName(java.lang.String lastName)
          Set the lastName for this OkapiUser.
 void setLocalID(java.lang.String localID)
          Set the localID for this OkapiUser.
 void setMiddleName(java.lang.String middleName)
          Set the middleName for this OkapiUser.
 void setNickName(java.lang.String nickName)
          Set the nickName for this OkapiUser.
 void setPreferenceProperties(java.util.Properties newPreferenceProperties)
          Set all preferenceProperties for this user.
 void setPreferenceProperty(java.lang.String key, java.lang.String value)
          Add or update specifed preferenceProperty for this user.
 void setStatus(int newStatus)
          Method setStatus Status codes: 0 - normal, 10 - sponsored, 18 - sponsored but password not set, 19 - pending sponsored 9 - deleted 11 - Created from Touchstone
 void setUserCode(int userCode)
          Set userCode for this user.
 void setUserName(java.lang.String userName)
          Set the userName for this OkapiUser.
 void updateDB()
          Update the database record for this object.
 
Methods inherited from class okapi.coreobjects.OkapiObject
currentDateTimeOracle, getAsXml, getAsXml, getAsXml, getCreatedBy, getCreatedDate, getDescription, getLastModifiedBy, getLastModifiedDate, getLongName, getName, getObjectID, getStatus, isEncryptionRequired, setAuthorization, setCreatedBy, setCreatedDate, setDescription, setLastModifiedBy, setLastModifiedBy, setLastModifiedDate, setLongName, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

superUser

public static OkapiUser superUser
Systemwide standard users for internal utility. superUser is 'root', can access anything. 'nobodyUser' is anonymous. nullUser has not authenticated


nobodyUser

public static OkapiUser nobodyUser

nullUser

public static OkapiUser nullUser

studentRoleUser

public static OkapiUser studentRoleUser

learnerRoleUser

public static OkapiUser learnerRoleUser

instructorRoleUser

public static OkapiUser instructorRoleUser

graderRoleUser

public static OkapiUser graderRoleUser

taRoleUser

public static OkapiUser taRoleUser

course_administratorRoleUser

public static OkapiUser course_administratorRoleUser

guestRoleUser

public static OkapiUser guestRoleUser

managerRoleUser

public static OkapiUser managerRoleUser

mentorRoleUser

public static OkapiUser mentorRoleUser

content_developerRoleUser

public static OkapiUser content_developerRoleUser

system_administratorRoleUser

public static OkapiUser system_administratorRoleUser

help_desk_staffRoleUser

public static OkapiUser help_desk_staffRoleUser

PERSONAL

public static final java.util.HashMap PERSONAL
Options constant for getAsXml methods indicating personal information only.

Constructor Detail

OkapiUser

public OkapiUser()
Create a new empty User Object. Fields from the superclass Object class have particular meaning: name is the username longName is the full name description is not used


OkapiUser

public OkapiUser(int userCode)
Return new User object with values for user with this userCode


OkapiUser

public OkapiUser(java.lang.String username)
Return new User object for user with this username.

Method Detail

resetAuthorization

public void resetAuthorization()
Method resetAuthorization


cacheCheck

public static int cacheCheck()
Method cacheCheck

Returns:
int

cacheNameCheck

public static int cacheNameCheck()
Method cacheNameCheck

Returns:
int

getUser

public static OkapiUser getUser(int userCode)
Get a user from the cache if cached, instantiate and add to cache if not.


getUser

public static OkapiUser getUser(java.lang.String username)
Get a user from the cache if cached, instantiate and add to cache if not.


refreshUser

public static OkapiUser refreshUser(java.lang.String username)
Refresh user in the cache if cached, instantiate and add to cache if not. Needed to reset authorization.


lookupUsers

public static java.util.List lookupUsers(java.lang.String nameQuery)
Return list of users matching query


lookupUserByEmail

public static OkapiUser lookupUserByEmail(java.lang.String email)
Return user with given email address, or null


getUserName

public java.lang.String getUserName()
Return the userName for this OkapiUser.


setUserName

public void setUserName(java.lang.String userName)
Set the userName for this OkapiUser.


getFullName

public java.lang.String getFullName()
Return the fullName for this OkapiUser.


setFullName

public void setFullName(java.lang.String fullName)
Set the fullName for this OkapiUser.


getFirstName

public java.lang.String getFirstName()
Return the firstName for this OkapiUser.


setFirstName

public void setFirstName(java.lang.String firstName)
Set the firstName for this OkapiUser.


getMiddleName

public java.lang.String getMiddleName()
Return the middleName for this OkapiUser.


setMiddleName

public void setMiddleName(java.lang.String middleName)
Set the middleName for this OkapiUser.


getLastName

public java.lang.String getLastName()
Return the lastName for this OkapiUser.


setLastName

public void setLastName(java.lang.String lastName)
Set the lastName for this OkapiUser.


getNickName

public java.lang.String getNickName()
Return the nickName for this OkapiUser.


setNickName

public void setNickName(java.lang.String nickName)
Set the nickName for this OkapiUser.


getAffiliation

public java.lang.String getAffiliation()
Return the affiliation for this OkapiUser.


setAffiliation

public void setAffiliation(java.lang.String affiliation)
Set the affiliation for this OkapiUser.


getLocalID

public java.lang.String getLocalID()
Return the localID for this OkapiUser.


setLocalID

public void setLocalID(java.lang.String localID)
Set the localID for this OkapiUser.


getEmail

public java.lang.String getEmail()
Return the email address for this OkapiUser.


setEmail

public void setEmail(java.lang.String email)
Set the email address for this OkapiUser.


getAttributes

public java.util.Map getAttributes()
Return the attributes Hashtable for this OkapiUser.


setAttribute

public void setAttribute(java.lang.Object key,
                         java.lang.Object value)
Set an attribute for this OkapiUser.


getAttributeByKey

public java.lang.Object getAttributeByKey(java.lang.Object key)
Return an attribute for this OkapiUser.

Parameters:
key -
Returns:
Object matching key

setUserCode

public void setUserCode(int userCode)
Set userCode for this user.


getUserCode

public int getUserCode()
Return userCode of this user.


setStatus

public void setStatus(int newStatus)
Method setStatus Status codes: 0 - normal, 10 - sponsored, 18 - sponsored but password not set, 19 - pending sponsored 9 - deleted 11 - Created from Touchstone

Overrides:
setStatus in class OkapiObject
Parameters:
newStatus -

equals

public boolean equals(java.lang.Object o)
override Object equals method to compare two users

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
override hashCode to use the database table sequence number

Overrides:
hashCode in class java.lang.Object

setPreferenceProperties

public void setPreferenceProperties(java.util.Properties newPreferenceProperties)
Set all preferenceProperties for this user.


getPreferenceProperties

public java.util.Properties getPreferenceProperties()
Return all preferenceProperties of this user.


getPreferenceProperty

public java.lang.String getPreferenceProperty(java.lang.String key)
Return specified preferenceProperties for this user.


getPreferenceProperty

public java.lang.String getPreferenceProperty(java.lang.String key,
                                              java.lang.String defaultValue)
Return specified preferenceProperties for this user, or the defaultValue if no preference is set.


setPreferenceProperty

public void setPreferenceProperty(java.lang.String key,
                                  java.lang.String value)
Add or update specifed preferenceProperty for this user.


setContactInfo

public void setContactInfo(java.util.Map newContactInfo)
Set all contactInfo for this user.


getContactInfo

public java.util.Map getContactInfo()
Return all contactInfo of this user.


getContactInfo

public OkapiUserContactInfo getContactInfo(java.lang.String type)
Return contactInfo of specified type for this user.


addContactInfo

public void addContactInfo(java.lang.String type,
                           OkapiUserContactInfo contactInfo)
Add or update contactInfo of specified type.


removeContactInfo

public void removeContactInfo(java.lang.String type)
Remove contactInfo of specified type for this user.


setAddresses

public void setAddresses(java.util.Map newAddresses)
Set all addresses for this user.


getAddresses

public java.util.Map getAddresses()
Return all addresses of this user.


getAddresses

public OkapiUserAddress getAddresses(java.lang.String type)
Return address of specified type for this user.


addAddresses

public void addAddresses(java.lang.String type,
                         OkapiUserAddress address)
Add or update address of specified type.


removeAddresses

public void removeAddresses(java.lang.String type)
Remove address of specified type for this user.


getSession

public OkapiSession getSession()
Method getSession

Returns:
okapi.util.OkapiSession

compareTo

public int compareTo(java.lang.Object o)
implement Comparable interface

Specified by:
compareTo in interface java.lang.Comparable

compareTo

public int compareTo(java.lang.String o)
Method compareTo

Parameters:
o -
Returns:
int

compareTo

public int compareTo(OkapiUser user)
Method compareTo

Parameters:
user -
Returns:
int

updateDB

public void updateDB()
Update the database record for this object.

Overrides:
updateDB in class OkapiObject

refreshFromDB

public void refreshFromDB()
Refresh this object with the data currently stored in the DB.

Overrides:
refreshFromDB in class OkapiObject

roleInNexus

public java.util.List roleInNexus(OkapiNexus nexus)
Return the User's Role(s) in the specified Nexus.


roleInNexus

protected java.util.List roleInNexus(java.lang.Integer nexusCode)
Return the User's Role(s) in the specified Nexus (by nexusCode).


getNexuses

public java.util.Map getNexuses()
Return the nexuses in which the User has a Role or Roles. Useful for portal apps.


checkAuthorization

public boolean checkAuthorization(OkapiUser user,
                                  OkapiOperation operation)
Checks to see if the specified user is authorized to perform the specified operation on this object.

Overrides:
checkAuthorization in class OkapiObject

getAsXml

public java.lang.String getAsXml(java.util.Map options,
                                 java.lang.String tag,
                                 int indent)
Overrides the method in OkapiObject to add Content specific information. See OkapiObject.getAsXml(String tag, int indent) for more information about using the getAsXml methods.

Overrides:
getAsXml in class OkapiObject

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Set the dataSource to be used for data access.

Parameters:
dataSource -


Copyright ? 2001-2009 MIT. All Rights Reserved.