Expresso 5-5-0

com.jcorporate.expresso.ext.dbobj
Class SingleDBUserInfo

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.BaseDataObject
      extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
          extended bycom.jcorporate.expresso.core.dbobj.DBObject
              extended bycom.jcorporate.expresso.core.dbobj.SecuredDBObject
                  extended bycom.jcorporate.expresso.ext.dbobj.SingleDBUserInfo
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Securable, Serializable, UserInfo

public class SingleDBUserInfo
extends SecuredDBObject
implements UserInfo

Version:
$Revision: 1.19 $ $Date: 2004/04/10 06:17:22 $
Author:
Michael Nash
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject
DBObject.FieldError, DBObject.FieldUpdate
 
Field Summary
static String FULL_NAME
          Field name for full name.
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
ADD, ALL_FUNCTIONS, CACHE_NAME, CACHE_TTY, DELETE, SEARCH, SYSTEM_ACCOUNT, SYSTEM_ACCOUNT_NAME, UPDATE
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.DBObject
ATTRIBUTE_ERROR, ATTRIBUTE_ERROR_MESSAGE, ATTRIBUTE_PAGE_LIMIT, BIG_DECIMAL_ZERO, EMAIL_MASK, FLOAT_MASK, INT_MASK, IS_CHECK_RELATIONAL_INTEGRITY
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
anyFieldsDistinct, anyFieldsToRetrieve, appendCustomWhere, caseSensitiveQuery, customWhereClause, dbKey, distinctFields, localConnection, maxRecords, myClassName, myUpdates, offsetRecord, recordSet, retrieveFields, sMetadataMap, sortKeys
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
currentStatus
 
Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED
 
Constructor Summary
SingleDBUserInfo()
           
SingleDBUserInfo(ControllerRequest request)
          For using DBObjects within Controllers.
SingleDBUserInfo(int uid)
          Use over (String) constructor.
 
Method Summary
 void add()
          Adds the current UserInfo object into the repository
protected  void checkAllRefs()
          Extends the checkAllRefs method to check for valid Registration Domain Id
 void delete()
          Deletes the current UserInfo object from the repository
 String getAccountStatus()
          Retrieve the current account status.
 Vector getAllUsers()
          Returns a Vector of all the UserInfo objects in the repository
 String getCreateDate()
          Returns the date that this UserInfo object was created
 String getDataContext()
          gets the DB context; can return null
 String getEmail()
          Returns the email address for this user
 String getEmailAuthCode()
          Returns the email auth code previously set for this user
 String getEmailValCode()
          Retrieve the validation code required for authorization by email
 String getFullName()
          get descriptive, full name
 Vector getGroups()
          Return a vector of the group names that this user belongs to
 String getLoginName()
          Returns the login name of this user
 String getPassword()
          Returns the password for this user
 String getPrimaryGroup()
          the primary group of this user is appropriate for unix-like purposes, such as setting the group for a file permission
 boolean getRegComplete()
          Returns the status of whether extended registration has been completed or not Valid values are "Y" or "N"
 String getRegistrationDomain()
          Returns the unique integer for the registration domain that this user belongs to
 int getUid()
          Returns the user id for this user
 String getUpdateDate()
          Returns the date that this UserInfo object was last modified
 String getUserName()
          Deprecated. Since Expresso 5.5; use getFullName() instead to avoid confusion with login name
 Vector getValidValues(String fieldName)
          New method to replace getValues with a structure of valid values and descriptions.
 void notify(String subject, String message)
          Send this user a notification via e-mail.
 boolean passwordEquals(String tryPassword)
          passwordEquals - feed it a password and it will tell you if the hash of it matches the one on file.
 void postLogin()
          Called by the various objects that can log in a user to do post-login tasks
 String randomPassword()
           
 void retrieve()
          Retrieves the current user from the repository
 void sendAuthEmail()
          Sends an Authorization Email to a new User.
 void sendFileTo(String subject, String message, Vector fileNames)
          Send this user an e-mail with file attachments.
 void sendFollowUpEmail()
          Once a user has validated his email address through the email validation servlet, the user will receive this message giving previously requested username/password.
 void setAccountStatus(String accountStatus)
          Sets the current status of the account - "A" (active), "D" (disabled), "I" (inactive)
 void setDBName()
           
 void setEmail(String email)
          Sets the email address
 void setEmailValCode(String code)
          Sets the code required for auth. via email
 void setLoginName(String loginName)
          Sets the login name
 void setPassword(String password)
          Sets the password
 void setRegComplete(boolean status)
          Sets the extended registration complete flag - "Y" or "N"
 void setRegistrationDomain(String domain)
          Sets the registration domain
 void setUid(int uid)
          Sets the user UID
 void setUid(String uid)
           
 void setupFields()
          Method to set up the fields for this database object.
 void setUserName(String name)
          Sets the user name
 void update()
          Update the user in the repository with modified properties
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, deleteAll, find, getCharset, getDescription, getDescription, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, getUser, instantiate, isAllowed, search, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid, setUser
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.DBObject
addCacheEventListener, addDetail, addField, addField, addFieldError, addFoundKeys, addIfNeeded, addIndex, addKey, addOrUpdate, addSortKey, addToCache, addTransition, addVirtualField, addVirtualField, addVirtualField, addVirtualField, allowsNull, average, basicAdd, checkAllReferredToBy, checkAllRefsPublic, checkDeleteDetailPerm, checkField, checkRef, checkRef, clear, clearDistinctFields, clearError, clearFieldsToRetrieve, clearSortKeys, containsWildCards, delete, deleteDetails, denotesRange, disableLogging, enableLogging, equals, forKey, formatDateTime, get, getAllAttributes, getAllDBFields, getAllFields, getAllFieldsIterator, getAllFieldsMap, getAllKeys, getAllKeysIterator, getAllKeysMap, getAttribute, getAttribute, getAttributesIterator, getBinaryField, getBooleanFieldValue, getCacheSize, getCacheStats, getCacheStatsMap, getCheckZeroUpdate, getCustomWhereClause, getDataField, getDataTransferObject, getDBName, getDefaultValue, getDetailFieldsForeign, getDetailFieldsLocal, getDetails, getDistinctFieldCount, getDistinctFieldList, getDistinctFields, getField, getFieldBigDecimal, getFieldBoolean, getFieldByte, getFieldData, getFieldDate, getFieldDecimalFormatted, getFieldDouble, getFieldErrorMessage, getFieldFloat, getFieldInt, getFieldList, getFieldListArray, getFieldListIterator, getFieldLong, getFieldMetaData, getFields, getFieldShort, getFieldsToRetrieveCount, getFilterClass, getFoundCount, getFoundKeys, getFoundKeysArray, getIndexArray, getISOValuesDefault, getISOValuesDefault, getISOValuesDefault, getKey, getKeyFieldList, getKeyFieldListArray, getKeyFieldListIterator, getLength, getLengthInt, getLimitationPosition, getLimitationSyntax, getLocalConnection, getLocale, getLookupObject, getMax, getMax, getMaxRecords, getMyKeys, getMyUpdates, getMyUpdatesArray, getName, getOffsetRecord, getOriginalDBName, getPatternMatcher, getPrecision, getRecordSet, getRecordSetArrayList, getSchema, getSerializedForm, getStringFilter, getTableName, getTargetTable, getThisDBbj, getThisDBObj, getTransitionsIterator, getType, getValidValueDescrip, getValidValuesList, getValues, getValuesDefault, getValuesDefault, getValuesDefault, hasError, hasErrors, hasField, hasIndex, haveAllKeys, initialize, isCached, isDateType, isDistinct, isEmpty, isField, isFieldDistinct, isFieldIgnoreCase, isFieldNull, isFieldsToRetrieve, isFieldToRetrieve, isMultiValued, isNumericType, isQuotedType, isReadOnly, isSecret, isVirtual, loadFromConnection, logChange, max, min, newInstance, noNewLine, noQuotes, notifyListeners, populateDefaultValues, referredToBy, removeAttribute, removeAttribute, removeFromCache, retrieveFromCache, saveBinaryField, saveBinaryField, search, set, setAttribute, setAttribute, setCacheSize, setCharset, setCheckZeroUpdate, setConnection, setConnection, setCustomWhereClause, setCustomWhereClause, setDataContext, setDataField, setDataTransferObject, setDefaultValue, setDescription, setField, setField, setField, setField, setField, setField, setField, setField, setField, setFieldData, setFieldDistinct, setFieldsToRetrieve, setFilterClass, setFilterClass, setKeys, setLocale, setLookupField, setLookupObject, setMask, setMaxRecords, setMultiValued, setName, setOffsetRecord, setReadOnly, setSchema, setSchema, setSecret, setSortKey, setStringFilter, setStringFiltersOnAll, setTargetTable, sqlAggrFunction, sum, toDebugString, update, verify
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
buildWhereClause, buildWhereClauseBuffer, checkZeroUpdate, constructNewMetaData, createAndExecuteSearch, getConnectionPool, getCustomStringFieldValue, getDef, getDistinctFieldArrayList, getExecutor, getFieldsToRetrieveIterator, getJDBCMetaData, getJDBCUtil, getMappedDataContext, getMetaData, getQueryInterface, getSerialForm, loadFromConnection, makeLimitationStub, quoteIfNeeded, selectFieldString, setCaseSensitiveQuery, setDBConnectionPool, setDBName, setMappedDataContext, setOriginalDBName
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
getStatus, setStatus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jcorporate.expresso.core.security.UserInfo
find, getDBName, getField, setDBName
 
Methods inherited from interface com.jcorporate.expresso.core.dbobj.LookupInterface
getValues
 

Field Detail

FULL_NAME

public static final String FULL_NAME
Field name for full name.

See Also:
Constant Field Values
Constructor Detail

SingleDBUserInfo

public SingleDBUserInfo()
                 throws DBException

SingleDBUserInfo

public SingleDBUserInfo(int uid)
                 throws DBException
Use over (String) constructor. Initializes the object in the context of the user who's uid belongs to the parameter.

Parameters:
uid - the Uid of the user context
Throws:
DBException - if there's an initialization problem

SingleDBUserInfo

public SingleDBUserInfo(ControllerRequest request)
                 throws DBException
For using DBObjects within Controllers. Initializes based upon the current user and the requested db. [Of course this can be modified later]

Parameters:
request - - The controller request handed to you by the framework.
Throws:
DBException
Method Detail

setUid

public void setUid(String uid)
            throws DBException
Throws:
DBException

setUid

public void setUid(int uid)
            throws DBException
Description copied from interface: UserInfo
Sets the user UID

Specified by:
setUid in interface UserInfo
Parameters:
uid - The uid of the user
Throws:
DBException - If there is an error

setDBName

public void setDBName()

getDataContext

public String getDataContext()
Description copied from interface: UserInfo
gets the DB context; can return null

Specified by:
getDataContext in interface UserInfo
Overrides:
getDataContext in class DBObject
Returns:
java.lang.String

add

public void add()
         throws DBException
Description copied from interface: UserInfo
Adds the current UserInfo object into the repository

Specified by:
add in interface UserInfo
Overrides:
add in class SecuredDBObject
Throws:
DBException - If the user is not permitted to add or if the add fails

checkAllRefs

protected void checkAllRefs()
                     throws DBException
Extends the checkAllRefs method to check for valid Registration Domain Id

Overrides:
checkAllRefs in class DBObject
Throws:
DBException - If a referential integrity violation is found

delete

public void delete()
            throws DBException
Description copied from interface: UserInfo
Deletes the current UserInfo object from the repository

Specified by:
delete in interface UserInfo
Overrides:
delete in class SecuredDBObject
Throws:
DBException - if delete is not allowed for the current user

getAccountStatus

public String getAccountStatus()
                        throws DBException
Description copied from interface: UserInfo
Retrieve the current account status. Valid values are "A" (active), "I" (inactive), "D" (disabled)

Specified by:
getAccountStatus in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If the find fails

getAllUsers

public Vector getAllUsers()
                   throws DBException
Description copied from interface: UserInfo
Returns a Vector of all the UserInfo objects in the repository

Specified by:
getAllUsers in interface UserInfo
Returns:
java.util.Vector
Throws:
DBException - If there is an error during the retrieval

getCreateDate

public String getCreateDate()
                     throws DBException
Description copied from interface: UserInfo
Returns the date that this UserInfo object was created

Specified by:
getCreateDate in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getEmail

public String getEmail()
                throws DBException
Description copied from interface: UserInfo
Returns the email address for this user

Specified by:
getEmail in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getEmailAuthCode

public String getEmailAuthCode()
                        throws DBException
Description copied from interface: UserInfo
Returns the email auth code previously set for this user

Specified by:
getEmailAuthCode in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getEmailValCode

public String getEmailValCode()
                       throws DBException
Description copied from interface: UserInfo
Retrieve the validation code required for authorization by email

Specified by:
getEmailValCode in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If the find fails

getGroups

public Vector getGroups()
                 throws DBException
Description copied from interface: UserInfo
Return a vector of the group names that this user belongs to

Specified by:
getGroups in interface UserInfo
Returns:
Vector Group names that this user belongs to
Throws:
DBException - If an error occurs when the group info is read

getLoginName

public String getLoginName()
                    throws DBException
Description copied from interface: UserInfo
Returns the login name of this user

Specified by:
getLoginName in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getPassword

public String getPassword()
                   throws DBException
Description copied from interface: UserInfo
Returns the password for this user

Specified by:
getPassword in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getRegComplete

public boolean getRegComplete()
                       throws DBException
Description copied from interface: UserInfo
Returns the status of whether extended registration has been completed or not Valid values are "Y" or "N"

Specified by:
getRegComplete in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getRegistrationDomain

public String getRegistrationDomain()
                             throws DBException
Description copied from interface: UserInfo
Returns the unique integer for the registration domain that this user belongs to

Specified by:
getRegistrationDomain in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If the underlying User implementation throws the same

getUid

public int getUid()
           throws DBException
Description copied from interface: UserInfo
Returns the user id for this user

Specified by:
getUid in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getUpdateDate

public String getUpdateDate()
                     throws DBException
Description copied from interface: UserInfo
Returns the date that this UserInfo object was last modified

Specified by:
getUpdateDate in interface UserInfo
Returns:
java.lang.String
Throws:
DBException - If there is an error during the retrieval

getUserName

public String getUserName()
                   throws DBException
Deprecated. Since Expresso 5.5; use getFullName() instead to avoid confusion with login name

get descriptive, full name

Specified by:
getUserName in interface UserInfo
Overrides:
getUserName in class SecuredDBObject
Returns:
String: The user login name of the user accessing this object
Throws:
DBException - if the user name is invalid

getFullName

public String getFullName()
                   throws DBException
get descriptive, full name

Throws:
DBException

getValidValues

public Vector getValidValues(String fieldName)
                      throws DBException
Description copied from class: DBObject
New method to replace getValues with a structure of valid values and descriptions. Database objects should extend this method to return Vectors of ValidValue objects for multi-valued fields. A specific object can return it's own list of ValidValues, or it can call this super method to use the lookup object to get the list of valid values instead.

Overrides:
getValidValues in class DBObject
Parameters:
fieldName - The name of the field to get the valid values for
Returns:
java.util.Vector of ValidValue objects
Throws:
DBException - The exception description.

notify

public void notify(String subject,
                   String message)
            throws DBException,
                   LogException
Send this user a notification via e-mail.

Parameters:
subject - Subject of the e-mail
message - Message to send in body of e-mail
Throws:
DBException - If the mail message cannot be sent
LogException

passwordEquals

public boolean passwordEquals(String tryPassword)
                       throws DBException
passwordEquals - feed it a password and it will tell you if the hash of it matches the one on file. Also, for backwards compatability and some other issues, this function will also accept a plaintext version of the password if it is sitting in the database. However, if a plaintext match is encountered, then it will hash the password and re-write itself to the database record.

Specified by:
passwordEquals in interface UserInfo
Parameters:
tryPassword - The value the user input for an attempted login.
Returns:
true if the compared password equals
Throws:
DBException

postLogin

public void postLogin()
               throws DBException,
                      LogException
Called by the various objects that can log in a user to do post-login tasks

Throws:
DBException
LogException

randomPassword

public String randomPassword()
Returns:
a new random generated password

sendAuthEmail

public void sendAuthEmail()
                   throws DBException
Sends an Authorization Email to a new User. The user must click on the link encoded in this email before his account will be activated.

Specified by:
sendAuthEmail in interface UserInfo
Throws:
DBException

sendFileTo

public void sendFileTo(String subject,
                       String message,
                       Vector fileNames)
                throws DBException,
                       LogException
Send this user an e-mail with file attachments.

Parameters:
subject - Subject of the e-mail
message - Message to send in body of e-mail
fileNames - of the files to attach
Throws:
DBException - If the mail message cannot be sent
LogException

sendFollowUpEmail

public void sendFollowUpEmail()
                       throws DBException
Once a user has validated his email address through the email validation servlet, the user will receive this message giving previously requested username/password. Creation date: (8/8/00 11:44:26 PM) author: Adam Rossi, PlatinumSolutions, Inc.

Specified by:
sendFollowUpEmail in interface UserInfo
Throws:
DBException - The exception description.

setAccountStatus

public void setAccountStatus(String accountStatus)
                      throws DBException
Description copied from interface: UserInfo
Sets the current status of the account - "A" (active), "D" (disabled), "I" (inactive)

Specified by:
setAccountStatus in interface UserInfo
Parameters:
accountStatus - java.lang.String
Throws:
DBException - If there is an error

setEmail

public void setEmail(String email)
              throws DBException
Description copied from interface: UserInfo
Sets the email address

Specified by:
setEmail in interface UserInfo
Parameters:
email - java.lang.String
Throws:
DBException - If there is an error

setEmailValCode

public void setEmailValCode(String code)
                     throws DBException
Description copied from interface: UserInfo
Sets the code required for auth. via email

Specified by:
setEmailValCode in interface UserInfo
Parameters:
code - java.lang.String
Throws:
DBException - If there is an error

setLoginName

public void setLoginName(String loginName)
                  throws DBException
Description copied from interface: UserInfo
Sets the login name

Specified by:
setLoginName in interface UserInfo
Parameters:
loginName - java.lang.String
Throws:
DBException - If there is an error

setPassword

public void setPassword(String password)
                 throws DBException
Description copied from interface: UserInfo
Sets the password

Specified by:
setPassword in interface UserInfo
Parameters:
password - java.lang.String
Throws:
DBException - If there is an error

setRegComplete

public void setRegComplete(boolean status)
                    throws DBException
Description copied from interface: UserInfo
Sets the extended registration complete flag - "Y" or "N"

Specified by:
setRegComplete in interface UserInfo
Parameters:
status - java.lang.String
Throws:
DBException - If there is an error

setRegistrationDomain

public void setRegistrationDomain(String domain)
                           throws DBException
Description copied from interface: UserInfo
Sets the registration domain

Specified by:
setRegistrationDomain in interface UserInfo
Parameters:
domain - java.lang.String
Throws:
DBException - If there is an error
See Also:
RegistrationDomain

setupFields

public void setupFields()
                 throws DBException
Description copied from class: DBObject
Method to set up the fields for this database object. This method should be defined in the implementing object and should make calls to addField, addKey, setMultiValued, etc. as required to define the content of the DBObject. Each setupFields method should call "super.setupFields()" so that field definitions can be "inheritcable"

Overrides:
setupFields in class DBObject
Throws:
DBException
See Also:
DBObject.setupFields()

setUserName

public void setUserName(String name)
                 throws DBException
Description copied from interface: UserInfo
Sets the user name

Specified by:
setUserName in interface UserInfo
Parameters:
name - java.lang.String
Throws:
DBException - If there is an error

update

public void update()
            throws DBException
Description copied from interface: UserInfo
Update the user in the repository with modified properties

Specified by:
update in interface UserInfo
Overrides:
update in class SecuredDBObject
Throws:
DBException

retrieve

public void retrieve()
              throws DBException
Description copied from interface: UserInfo
Retrieves the current user from the repository

Specified by:
retrieve in interface UserInfo
Overrides:
retrieve in class SecuredDBObject
Throws:
DBException - if search is not allowed or if no record is found

getPrimaryGroup

public String getPrimaryGroup()
                       throws DBException
the primary group of this user is appropriate for unix-like purposes, such as setting the group for a file permission

Specified by:
getPrimaryGroup in interface UserInfo
Returns:
name of the primary group of this user; null if no group is primary
Throws:
DBException

Expresso 5-5-0

Please see www.jcorporate.com for information about new Expresso releases.